﻿//
// Copyright © MixModes Inc. 2011
//

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Markup;

namespace MixModes.Phone.Synergy.Framework
{
    /// <summary>
    /// View selector
    /// </summary>
    [ContentProperty("ViewBindings")]
    public class ViewSelector : IDisposable
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewSelector"/> class.
        /// </summary>
        public ViewSelector()
        {
            ViewBindings = new List<ViewBinding>();

            if (!DesignerProperties.IsInDesignTool)
            {
                PhoneApplication.Instance.RegisterViewSelector(this);
            }
        }

        /// <summary>
        /// Gets or sets the view bindings.
        /// </summary>
        /// <value>The view bindings.</value>
        public List<ViewBinding> ViewBindings
        {
            get;
            private set;
        }

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            PhoneApplication.Instance.UnregisterViewSelector(this);
        }
    }
}
